package view.toolbar.loading
{
	import fl.core.UIComponent;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	import model.ActionEvent;
	import model.Application;
	
	public class Loading extends Sprite
	{
		private var _loading:UILoading;
		private var _stage:UtbGame;
		
		public function Loading()
		{
			_loading = new UILoading;
			addChild(_loading);	
			
			Application.instance().addEventListener(ActionEvent.EVENT_NAME, onAction);
		}
		
		private function onAction(e:ActionEvent):void
		{
			if(e.stateName&Application.STATE_SHOW_USER_INFO){
				if (this.parent) parent.removeChild(this);
			}
		}
		
		public function set gameStage(value:UtbGame):void{
			_stage = value;
		}
		
		public function set bgVisible(value:Boolean):void{
			_loading.bg.visible = value;
		}
		
		public function set infoValue(value:String):void{
			
			if (value == ""){
				if (this.parent) this.parent.removeChild(this);
			}
			else{
				_loading.info.txt.text = value;
				_stage.addChild(this);
			}
			
		}
	}
}